Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/sso/[id].tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { r_human_list } from "@cocalc/frontend/components/r_human_list";6import { Button, Layout, Typography } from "antd";7import Footer from "components/landing/footer";8import Head from "components/landing/head";9import Header from "components/landing/header";10import Main from "components/landing/main";11import SanitizedMarkdown from "components/misc/sanitized-markdown";12import { ssoNav } from "components/sso";13import basePath from "lib/base-path";14import { Customize, CustomizeType } from "lib/customize";15import { getOneSSO } from "lib/sso/sso";16import withCustomize from "lib/with-customize";17import Link from "next/link";18import { join } from "path";19import { SSO_SUBTITLE } from ".";2021const { Paragraph, Text } = Typography;2223interface Props {24customize: CustomizeType;25id: string;26descr?: string;27display: string;28icon?: string;29domains: string[];30}3132export default function Signup(props: Props) {33const { id, descr, display, icon, domains, customize } = props;3435function renderDescr() {36const fallback = `If you have an account at this provider,37you can signup here to get access to ${customize.siteName}.`;38const md = `## ${display}\n\n${descr ?? fallback}`;39return <SanitizedMarkdown value={md} />;40}4142function renderIcon() {43if (icon == null) return null;44return (45<div style={{ float: "right" }}>46<img src={icon} width={100} height={100} />47</div>48);49}5051function renderExclusiveDomains() {52if (domains.length === 0) return null;53return (54<Paragraph>55This is required for email addresses at{" "}56{r_human_list(57(domains ?? []).map((d) => (58<Text code key={d}>59{d}60</Text>61))62)}63</Paragraph>64);65}6667function renderButton() {68const href = join(basePath, "auth", id);69return (70<Button71href={href}72type="primary"73size="large"74style={{ marginTop: "50px" }}75>76Sign up using {display}77</Button>78);79}8081function main() {82return (83<>84{renderIcon()}85{renderDescr()}86{renderExclusiveDomains()}87{renderButton()}88</>89);90}9192function nav(): JSX.Element[] {93return [...ssoNav(), <Link href={`/sso/{id}`}>{display}</Link>];94}9596return (97<Customize value={customize}>98<Head title={`${SSO_SUBTITLE} – ${display}`} />99<Layout style={{ background: "white" }}>100<Header />101<Main nav={nav()}>{main()}</Main>102<Footer />103</Layout>104</Customize>105);106}107108export async function getServerSideProps(context) {109const { id } = context.params;110const info = await getOneSSO(id);111return await withCustomize({ context, props: { ...info } });112}113114115